package com.e3.basdoc.measure.client;

import java.util.List;

import com.e3.basdoc.measure.model.MeasureUnitModel;
import com.e3.basdoc.measure.model.MeasureUnitQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.e3.web.widget.client.MyField;
import com.extjs.gxt.ui.client.widget.form.Field;

public class MeasureUnitQueryDialog extends TGFQueryDialog<MeasureUnitModel> {
	
	private MeasureUnitRPCServiceAsync service = MeasureUnitRPCService.Util.getInstance();

	@Override
	protected List<Field<?>> getFormFields() {
		return MeasureUnitHelper.INSTANCE.getFormFields();
	}
	
	@Override
	protected SuperQC getQueryCondition() {
		MyField<?> field = getMyFormField(MeasureUnitModel.CODE);
		String code = (String)field.getFieldValue();
		field = getMyFormField(MeasureUnitModel.NAME);
		String name = (String)field.getFieldValue();
		
		final MeasureUnitQC qc = new MeasureUnitQC();
		qc.setCode(code);
		qc.setName(name);
		return qc;
	}

	@Override
	protected void executeQueryService(SuperQC qc,GwtAsyncCallback<List<MeasureUnitModel>> callback) {
		service.getMeasureUnitByCondition((MeasureUnitQC)qc, getQueryAsyncCallBack(qc));
	}


}
